﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using EzDesk.Project.Model;
using EzDesk.Utility.Web.Extensions;
using EzDesk.EzAppApi.Utility.EzDeskAppApi;

namespace EzDesk.Project.DesktopWeb.Models
{
    public class GanttTaskModel
    {
        public GanttTaskModel() { }

        public GanttTaskModel(Task task)
        {
            this.Id = task.Id.ToString();
            this.Name = task.Name;
            this.Director = task.Director;
            this.StartOn = task.StartOn.ToEpoch();
            this.Duration = (int)((task.EndOn - task.StartOn).TotalHours);
            this.IsCompleted = task.IsClosed;
            this.DependencyId = "";
            this.ChildTasks = new GanttTaskModel[0];
        }
        
        public string Id { get; set; }
        public string Name { get; set; }
        public SimpleUser Director { get; set; }
        public int StartOn { get; set; }
        public int Duration { get; set; }
        public bool IsCompleted { get; set; }
        public string DependencyId { get; set; }
        public GanttTaskModel[] ChildTasks { get; set; }

        public string ClientAction { get; set; }
        public int ClientActionDate { get; set; }
    }
}